package com.sap.apitest2.dailyrun;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.util.*;


public class DailyRunServlet extends HttpServlet{

	Timer timer;
	@Override
	public void init() throws ServletException {
		
		super.init();
		
		timer = new Timer();
		
		System.out.println("***Timer has been started***");
		
		int oneDay = 1000 * 60 * 60 * 24;
		Date nowDate = new Date();
		int hours = nowDate.getHours();
		int delay = (24 - hours) * 60 * 60 * 1000 + 6000;
		
		timer.schedule(new DailyRunTask(), delay, oneDay);
		
		
		
	}
	

}